from util import get_session,Base
from sqlalchemy import Column, Integer, String


class UserMD(Base):
    __tablename__ = "user_t"


    id = Column(String(200), primary_key=True)
    name = Column(String(200),default='',nullable=True)
    bio = Column(String(500),default='',nullable=True)
    location = Column(String(200),default='',nullable=True)
    website = Column(String(500),default='',nullable=True)
    birth_date = Column(String(200),default='',nullable=True)
    following_count = Column(Integer,default=0,nullable=True)
    followers_count = Column(Integer,default=0,nullable=True)

    def save(self):
        with get_session() as s:
            s.add(self)
            s.commit()

    @staticmethod
    def get(id):
        with get_session() as s:
            user = s.query(UserMD).get(id)
        return user





class UserFollowingMap(Base):
    __tablename__ = "user_following_map_t"
    user_id = Column(String(200),primary_key=True)
    follower_id = Column(String(200),primary_key=True)
